@extends('layout.admin')

@section('title')
    <title>权限列表</title>
@endsection
 
@section('css')

@endsection

@section('content')

<div class="admin-content">
    <div class="daohang"></div>
    <div class=" admin-biaogelist" style="background: #fff">
		<section class="am-panel am-u-lg-12 am-fl am-panel-success roled" style="padding: 0px; float: left;">
			<header class="am-panel-hd">
				<h3 class="am-panel-title">
					<i class=" am-icon-tags" aria-hidden="true"></i>
					权限列表
				</h3>
			</header>
			<div class="am-panel-bd perms" style="font-size: 12px;">
				<table class="am-table am-table-bordered am-table-radius am-table-striped">
						<tr>		
							<th>ID</th>
							<th>名称</th>
							<th>显示名称</th>
							<th>描述</th>
							<th>创建时间</th>
						</tr>
					@foreach ($Permissions as $perm)
						<tr>
							<td>{{ $perm->id }}</td>
							<td class="name">{{ $perm->name }}</td>
							<td class="display_name">{{ $perm->display_name }}</td>
							<td class="description">{{ $perm->description }}</td>
							<td>{{ $perm->created_at }}</td>
							
						</tr>
					@endforeach
				</table>
			</div>
		</section>
		@include('common.footer')
	</div>
</div>
@endsection

@section('js')
<script type="text/javascript">
		$(function () {
			$('.checkboxs label:first').attr('style', 'margin-left: 10px;');
			$('.perms p').attr('style', 'margin-left: 20px;');
			var roled = $('.roled');
			roled.each(function (i) {
				if ( (i + 1) % 5 == 0 ) {
					$(this).after('<div style="clear:both;"></div>');
				}
			});
		});
		$('.update').click(function () {
		//获取到当前要修改的源数据
			var name = $(this).parents('td').siblings('.name').html();
			var display_name = $(this).parents('td').siblings('.display_name').html();
			var description = $(this).parents('td').siblings('.description').html();
			var id = $(this).parents('tr').children('td').first().html();
			var url = $('.updates').attr('action');
		//赋予到修改表单
			$('.updates input[name="name"]').attr('value', name);
			$('.updates input[name="display_name"]').attr('value', display_name);
			$('.updates textarea').attr('value', description);
			$('.updates').attr('action', url+'/'+id);
			
		});

		//点击删除时的提示
		$('form.del').submit(function () {
		   return confirm('确定删除？');
		});
</script>
@endsection

@section('prompt')
    
@endsection
